﻿using CloudStorageLight.Core;
using Microsoft.InformationProtectionAndControl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace CloudStorageLight.Core.Web
{
    public class AppBlobDirectoryVM 
    {
        public List<BlobAccessToken> AccessTokens { get; set; }

        public string Path { get; set; }

        public string FilePasscode { get; set; }

        public int? MaxHistorySize { get; set; }

        public string RmsTemplateId { get; set; }

        public string ProtectedMode { get; set; }

        public bool? BackupMode { get; set; }

        public bool? SearchMode { get; set; }

        public bool? CaseInsensitive { get; set; }

        public bool? DecryptableFileOnly { get; set; }

        public bool? DownloadFromOriginalUrl { get; set; }

        public string UploadableFileExtension { get; set; }

        public string ProtectedModeValue { get; set; }

        public string MaxHistorySizeValue { get; set; }

        public string RmsTemplateIdValue { get; set; }

        public string BackupModeValue { get; set; }

        public string SearchModeValue { get; set; }

        public string CaseInsensitiveValue { get; set; }

        public string DecryptableFileOnlyValue { get; set; }

        public string DownloadFromOriginalUrlValue { get; set; }

        public string UploadableFileExtensionValue { get; set; }

        public List<SelectListItem> BackupModeList { get; set; }
        public List<SelectListItem> SearchModeList { get; set; }
        public List<SelectListItem> CaseInsensitiveList { get; set; }

        public List<SelectListItem> ProtectedModeList { get; set; }
        public List<SelectListItem> DecryptableFileOnlyList { get; set; }
        public List<SelectListItem> DownloadFromOriginalUrlList { get; set; }
        public List<SelectListItem> RmsTemplateIdList { get; set; }

        public string UsersRole { get; set; }

        public BlobUser User { get; set; }

        public AppBlobDirectoryVM()
        {
            BackupModeList = new List<SelectListItem>();
            BackupModeList.Add(new SelectListItem() { Text = "", Value = null });
            BackupModeList.Add(new SelectListItem() { Text = "ON", Value = "true" });
            BackupModeList.Add(new SelectListItem() { Text = "OFF", Value = "false" });

            SearchModeList = new List<SelectListItem>();
            SearchModeList.Add(new SelectListItem() { Text = "", Value = null });
            SearchModeList.Add(new SelectListItem() { Text = "ON", Value = "true" });
            SearchModeList.Add(new SelectListItem() { Text = "OFF", Value = "false" });

            CaseInsensitiveList = new List<SelectListItem>();
            CaseInsensitiveList.Add(new SelectListItem() { Text = "", Value = null });
            CaseInsensitiveList.Add(new SelectListItem() { Text = "ON", Value = "true" });
            CaseInsensitiveList.Add(new SelectListItem() { Text = "OFF", Value = "false" });

            DecryptableFileOnlyList = new List<SelectListItem>();
            DecryptableFileOnlyList.Add(new SelectListItem() { Text = "", Value = null });
            DecryptableFileOnlyList.Add(new SelectListItem() { Text = "ON", Value = "true" });
            DecryptableFileOnlyList.Add(new SelectListItem() { Text = "OFF", Value = "false" });

            DownloadFromOriginalUrlList = new List<SelectListItem>();
            DownloadFromOriginalUrlList.Add(new SelectListItem() { Text = "", Value = null });
            DownloadFromOriginalUrlList.Add(new SelectListItem() { Text = "ON", Value = "true" });
            DownloadFromOriginalUrlList.Add(new SelectListItem() { Text = "OFF", Value = "false" });

        }

        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.AppendFormat("Path:{0} ", this.Path != null ? this.Path.ToString() : "");
            sb.AppendFormat("RmsTemplateId:{0} ", this.RmsTemplateId != null ? this.RmsTemplateId.ToString() : "");
            sb.AppendFormat("ProtectedMode:{0} ", this.ProtectedMode != null ? this.ProtectedMode.ToString() : "");
            sb.AppendFormat("Backup:{0} ", this.BackupMode != null ? this.BackupMode.ToString() : "");
            sb.AppendFormat("AccessTokens:{0} ", this.AccessTokens != null ? string.Join(",",this.AccessTokens.Select(x=>x.Token ?? "")) : "");
            sb.AppendFormat("SearchMode:{0}", this.SearchMode != null ? this.SearchMode.ToString() : "");
            sb.AppendFormat("CaseInsensitive:{0}", this.CaseInsensitive != null ? this.CaseInsensitive.ToString() : "");
            sb.AppendFormat("DecryptableFileOnly:{0}", this.DecryptableFileOnly != null ? this.DecryptableFileOnly.ToString() : "");
            sb.AppendFormat("DownloadFromOriginalUrl:{0}", this.DownloadFromOriginalUrl != null ? this.DownloadFromOriginalUrl.ToString() : "");
            return sb.ToString();
        }
    }
}